package com.imooc.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.imooc.beans.Message;
import com.imooc.service.MessageService;
import com.sun.org.apache.bcel.internal.generic.SALOAD;





/**
 * 
 * 
 * @author Administrator
 *
 */
@SuppressWarnings("serial")
public class ListServlet extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		req.setCharacterEncoding("utf-8");
		String command = (String) req.getParameter("command");
		String description = (String) req.getParameter("description");
		req.setAttribute("command", command);
		req.setAttribute("description", description);
		
		
		MessageService messageService=new MessageService();
		List<Message> mList=messageService.queryMessageList(command, description);
		
		req.setAttribute("mList", mList);
		
		req.getRequestDispatcher("/WEB-INF/jsp/back/list.jsp").forward(req, resp);
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		
		
		this.doGet(req, resp);
	}
	

}
